#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>

#include "hash_object.h"
#include "new.h"

static Pointer hash_object_create(Pointer _self, va_list *app)
{
	char* bufstring;
	struct HashObject* self = _self;
	self->hash = va_arg(*app, unsigned int);
	self->data_size = va_arg(*app, size_t);
	self->data = calloc(1, self->data_size);
	memcpy(self->data, va_arg(*app, Pointer), self->data_size);
	bufstring=va_arg(*app, char*);
	self->key = (char*)calloc(strlen(bufstring) + 1, 1);
	strcpy(self->key, bufstring);
	return self;
}

static Pointer hash_object_destroy(Pointer _self)
{
	struct HashObject* self = _self;
	assert(self);
	free(self->data);
	free(self->key);
	return self;
}

static const struct Class _HashObject = {
    sizeof(struct HashObject),		
    hash_object_create,                 
    hash_object_destroy                 
};
 
const void *HashObject = &_HashObject;